<script setup>
import {ref,reactive} from "vue";
import axios from "axios"

let message = ref('');
let code = ref(0);

let msgObj=reactive({
    code:0,
    content:''
})

//get请求
// let getMessage = async()=>{
//     //解析-->解构
//     let {data} = await axios({
//         url:"http://forum.atguigu.cn/api/rand.qinghua?format=json",
//         method:"get",
//         params:{"参数1":"值1","参数2":"值2"}
//     })
//     //相当于拷贝
//     Object.assign(msgObj,data);
// }

//post请求
let getMessage = async()=>{
    //解析-->解构
    let {data} = await axios({
        url:"http://forum.atguigu.cn/api/rand.qinghua?format=json",
        method:"post",
        data:{"参数1":"值1","参数2":"值2"}
    })
    //相当于拷贝
    Object.assign(msgObj,data);
}

</script>

<template>
  <div>

    <button @click="getMessage()">土味情话</button>


    <h1>{{ msgObj }}</h1>
  </div>
</template>

<style scoped>

</style>
